package Offer;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: wangliuyang
 * @Date: 2021/6/9 16:52
 * @Description: 剑指 Offer 03. 数组中重复的数字
 */
class Solution {
    public int findRepeatNumber(int[] nums) {
        Set<Integer> set = new HashSet<Integer>();
        int repeat = -1;
        for (int num : nums) {
            if (!set.add(num)) {
                repeat = num;
                break;
            }
        }
        return repeat;
    }
}
